<template>
  <div>
    <h3>当前的count值:{{ count }}</h3>
    <button @click="btnSub">-1</button>
    <button @click="subX">-1</button>
  </div>
</template>

<script>
// 导入mapState函数
// 导入 mapMutations 函数
import { mapState, mapMutations } from 'vuex'

export default {
  data() {
    return {}
  },
  computed: {
    ...mapState(['count'])
  },
  methods: {
    btnSub() {
      this.$store.commit('subN')
    },
    ...mapMutations(['subX'])
  }
}
</script>

<style>
</style>